Skip to content

Conversation

@giortzisg
Copy link
Contributor

@giortzisg giortzisg commented Oct 7, 2025

Description

Add telemetry scheduler implementation and integrate with the client. The current PR also includes changes on the transport and envelope layer.

The proper solution for batching under the scheduler is to abstract each event type, so that it knows how to convert itself to an envelope item (noted as EnvelopeItemConvertible in the PR), and then the scheduler would just create envelopes using []EnvelopeItemConvertible. This partially fixes the issue, since currently everything is anchored around the Event type. We should also abstract all event types to implement EnvelopeItemConvertible in the future.

Notes

  • As discussed above, we need to change the EnvelopeConvertible to EnvelopeItemConvertible introduced in feat: add new envelope transport #1094. For the sake of clarity I added the changes here and not on the other PR. Same applies with ToEnvelope
  • Not 100% sure on how to approach metadata required on the EnvelopeHeader. Left some comments on the implementation.

Issues

@linear
Copy link

linear bot commented Oct 7, 2025

@giortzisg giortzisg changed the base branch from master to feat/transport-envelope October 7, 2025 12:37
@codecov
Copy link

codecov bot commented Oct 7, 2025

Codecov Report

❌ Patch coverage is 81.01266% with 120 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.79%. Comparing base (0c2bdf5) to head (1f821a2).

Files with missing lines Patch % Lines
internal/telemetry/bucketed_buffer.go 76.77% 42 Missing and 17 partials ⚠️
interfaces.go 80.26% 12 Missing and 3 partials ⚠️
internal/telemetry/scheduler.go 90.34% 9 Missing and 5 partials ⚠️
client.go 76.31% 6 Missing and 3 partials ⚠️
transport.go 50.00% 5 Missing and 3 partials ⚠️
internal/protocol/log_batch.go 70.00% 3 Missing and 3 partials ⚠️
internal/http/transport.go 80.95% 2 Missing and 2 partials ⚠️
log.go 62.50% 2 Missing and 1 partial ⚠️
internal/telemetry/buffer.go 91.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1107      +/-   ##
==========================================
- Coverage   86.93%   86.79%   -0.14%     
==========================================
  Files          60       62       +2     
  Lines        5555     6067     +512     
==========================================
+ Hits         4829     5266     +437     
- Misses        540      585      +45     
- Partials      186      216      +30     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@giortzisg giortzisg force-pushed the feat/telemetry-scheduler branch from 6c1fff1 to 2e16e4f Compare October 9, 2025 08:21
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Base automatically changed from feat/transport-envelope to master October 22, 2025 09:20
@lcian lcian self-requested a review October 22, 2025 10:17
}

func (s *Scheduler) processNextBatch() {
s.mu.Lock()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we even need a mutex? Is it even possible for this function to be called concurrently by 2 different goroutines?

Copy link
Member

@lcian lcian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation seems reasonable.
Left some comments.

I don't like too much how we need to store the dsn and sdkInfo in the scheduler.
We probably don't need to add too much stuff to it so it's okay if we cannot get rid of it.

cursor[bot]

This comment was marked as outdated.

@giortzisg giortzisg force-pushed the feat/telemetry-scheduler branch from 663a9eb to cda84db Compare October 24, 2025 11:36
cursor[bot]

This comment was marked as outdated.

Comment on lines +736 to +743
type logJSON struct {
Timestamp *float64 `json:"timestamp,omitempty"`
TraceID string `json:"trace_id,omitempty"`
Level string `json:"level"`
Severity int `json:"severity_number,omitempty"`
Body string `json:"body,omitempty"`
Attributes map[string]protocol.LogAttribute `json:"attributes,omitempty"`
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I see the reason why we need this type now, e.g. Timestamp is a time.Time but you want to serialize it as float64, etc.
In Rust (serde) you could do this using serialize_with: https://serde.rs/field-attrs.html#serialize_with 😎

envItem, err := item.ToEnvelopeItem()
if err != nil {
debuglog.Printf("error converting item: %v", err)
debuglog.Printf("error converting item to envelope: %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
debuglog.Printf("error converting item to envelope: %v", err)
debuglog.Printf("error converting item to envelope item: %v", err)

or

Suggested change
debuglog.Printf("error converting item to envelope: %v", err)
debuglog.Printf("error converting item: %v", err)

I guess

Copy link
Member

@lcian lcian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the diff, Looks Good To Me.

cursor[bot]

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Issue type

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create envelope scheduler

4 participants